package com.snopy.designPattern.structure.proxy.dynamic.jdk;

import java.lang.reflect.Proxy;

/**
 * @author snopy
 * @version 1.0.0
 * @classname PlatformDemo
 * @description jdk dynamic proxy important point:
 * 1. implemets InvocationHandle intefface
 * 2. use Proxy.newProxyInstance to produce proxy object
 * 代理类要实现java提供的接口，注入要代理的对象，指定要代理对象，生成代理对象的方法可以在集成在不通的地方
 * @email 77912204@qq.com
 * @date 2022/03/15 13:05
 */
public class PlatformDemo {
    public static void main(String[] args) {
        Star xxStar = new XXStar();
        StarProxy proxy = new StarProxy(xxStar);
        Star o = (Star)proxy.CreatProxyedObj();
        o.dancing();
        o.singing();

        Star o1 = (Star)Proxy.newProxyInstance(XXStar.class.getClassLoader(), XXStar.class.getInterfaces(), proxy);
        o1.singing();
        o1.dancing();

    }
}
